Flipbooks present code step-by-step and side-by-side with its output. The incremental code/result reveal may help you digest longer manipulation and analysis pipelines as well as plot builds.
Long pipelines of code can produce attractive outputs. But when an observer knows only initial input and final output, a pipeline may feel like a long stretch of highway that has no exit or entry ramps. Interacting with the same code that has been made into a flipbook is different; in a flipbook the user can isolate and gain insight about short streches along the pipeline that are useful for their particular project – all the while engaged by the creativity brought by the author in pursuit of their original goal. Flipbooks enable us to isolate how individual functions work in context.
The presentation of intermediate states on via slide-show presentation platform means that states can be aligned and superimposed. This way, the audience doesn’t need to engage in visual search which requires focus and concentration – but rather effortlessly observes changes as motion detection. Temporal rather than spatial offset makes it easy to notice changes to the code and the resultant changes to the output.
To get a sense of how they work, click once in the example box the below to initiate the session; then use the right and left arrow to “flip” through the book to see how to make an animated “racing” bar chart of the population size of the most populous countries over time.
Would you like to make a flipbook? We try to make that easy for you with {flipbookr}. To get started have a look at A minimal Flipbook, the template for which will be available once you install the flipbook building package {flipbookr}. The steps to building your first flipbook are as follows:
install.packages("xaringan")devtools::install_github("EvaMaeRey/flipbookr")Once you have completed steps 1-3, you can also follow along with the live demo that I presented at the RStudio Conference, 2020 (the demo is at 6’25") — but consider using the setup code chunk in the template — I don’t do this in the demo.
The template (step 4) will create the following book, which contains examples of flipbooking modes:
Here are a few known issues to watch for:
We’ve collected flipooks for reference into three categories.
You can link some flipbooks here:
If you need a theoretical exploration of the grammar of graphics and its use with ggplot2, see a ggplot2 grammar guide.
The geom pile on is a suppliment to the ggplot grammar guide and shows you a lot of “geoms” that you can use to communicate about your data. Piling up the geoms allows you to see how plot types relate to one another.
ggplot themes takes you through logic of the ggplot2 theme adjustments.
For examples of data wrangling/manipulation with pipelines and pipes (%>%), check out The Tidyverse in Action.
geom_sf gives you an example of using geom_sf with ggplot to create coordinate plots and choropleths.